package com.qishenyuan.competition.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qishenyuan.competition.common.PageResult;
import com.qishenyuan.competition.common.PageUtil;
import com.qishenyuan.competition.common.Response;
import com.qishenyuan.competition.dto.JobRecommendationReq;
import com.qishenyuan.competition.service.JobRecommendationService;
import com.qishenyuan.competition.vo.JobRecommendationBriefResp;
import com.qishenyuan.competition.vo.JobRecommendationResp;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * <p>
 * 内推职位信息表 前端控制器
 * </p>
 *
 * @author qishenyuan
 * @since 2025-03-25
 */
@RestController
@RequestMapping("/jobRecommendation")
public class JobRecommendationController {
    @Resource
    private JobRecommendationService jobRecommendationService;

    @RequestMapping("/getJobRecommendationList")
    Response<? extends Map> getJobRecommendationList(@RequestBody @Valid JobRecommendationReq jobRecommendationReq){
        IPage<JobRecommendationBriefResp> jobRecommendationList = jobRecommendationService.getJobRecommendationList(jobRecommendationReq);
        PageResult<JobRecommendationBriefResp> pageResult = PageUtil.toPageResult(jobRecommendationList);
        return Response.ok(pageResult);
    }

    @GetMapping("/getJobRecommendation/{id}")
    public Response<JobRecommendationResp> getJobRecommendation(@PathVariable Integer id){
        JobRecommendationResp jobRecommendation = jobRecommendationService.getJobRecommendation(id);
        if(jobRecommendation != null){
            return Response.ok(jobRecommendation);
        }else {
            return Response.failed("null");
        }
    }

}
